package cn.zn.modules.budget.cur.controller;

import cn.zn.framework.common.utils.PageUtils;
import cn.zn.framework.common.utils.R;
import cn.zn.modules.budget.cur.entity.TBudgetIncome;
import cn.zn.modules.budget.cur.service.TBudgetIncomeService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 预算收入
 *
 * @author zn
 * @email zhunahao@qq.com
 * @date 2019-12-10 14:27:52
 */
@RestController
@RequestMapping("budget/budgetincome")
public class TBudgetIncomeController {

    @Autowired
    private TBudgetIncomeService tBudgetIncomeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("budget:tbudgetincome:list")
    public R list(@RequestParam Map<String, Object> params) {

        PageUtils pageUtils = tBudgetIncomeService.queryPage(params);

        return R.ok().put("page", pageUtils);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("budget:tbudgetincome:info")
    public R info(@PathVariable("id") String id) {
        TBudgetIncome tBudgetIncome = tBudgetIncomeService.getById(id);

        return R.ok().put("budgetincome", tBudgetIncome);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("budget:tbudgetincome:save")
    public R save(@RequestBody TBudgetIncome tBudgetIncome) {
            tBudgetIncomeService.save(tBudgetIncome);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("budget:tbudgetincome:update")
    public R update(@RequestBody TBudgetIncome tBudgetIncome) {
            tBudgetIncomeService.updateById(tBudgetIncome);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("budget:tbudgetincome:delete")
    public R delete(@RequestBody String[] ids) {
        tBudgetIncomeService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
